/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.jbr.simplefoodplan.gwt.client;

import com.google.gwt.core.client.JavaScriptObject;
import com.google.gwt.i18n.client.DateTimeFormat;
import java.util.Date;

/**
 *
 * @author jbr
 */
public class Plan extends JavaScriptObject {
    protected Plan() {};





    public final native Dish getDish() /*-{return this.dish;}-*/;
    public final native void setDish(Dish dish) /*-{this.dish=dish;}-*/;
    public final native String getDishId() /*-{return this.dishId;}-*/;
    public final native void setDishId(String dishId) /*-{this.dishId=dishId;}-*/;
    public final native String getId() /*-{return this.id;}-*/;
    public final native String getRawDate() /*-{return this.date;}-*/;
    public final native void setRawDate(String date) /*-{this.date=date;}-*/;


    public final Date getDate() {
        if (getRawDate() == null)
            return null;
        return MainEntryPoint.jsonFormat.parse(getRawDate().substring(0, 10));
    }

    public final String getDateAsString() {
        final DateTimeFormat userFormat = DateTimeFormat.getFormat(
                DateTimeFormat.PredefinedFormat.DATE_FULL);
        return userFormat.format(getDate());

    }


}
